package com.gitee.wsl.mathematics.vector.ext

import com.gitee.wsl.mathematics.vector.vec2.Vector2
import com.gitee.wsl.mathematics.vector.vec3.Vector3
import com.gitee.wsl.mathematics.vector.vec4.Vector4

fun<N:Number> Vector2<N, *>.map(beforeLeft: Vector2<N, *>, beforeRight: Vector2<N, *>,
                                afterLeft: Vector2<N, *>, afterRight: Vector2<N, *>,
                                clamp: Boolean = false) =
    create(
        x.map(beforeLeft.x, beforeRight.x, afterLeft.x, afterRight.x, clamp),
        y.map(beforeLeft.y, beforeRight.y, afterLeft.y, afterRight.y, clamp)
    )

fun <N:Number> Vector3<N, *>.map(beforeLeft: Vector3<N, *>, beforeRight: Vector3<N, *>,
                                 afterLeft: Vector3<N, *>, afterRight: Vector3<N, *>,
                                 clamp: Boolean = false) =
    create(
        x.map(beforeLeft.x, beforeRight.x, afterLeft.x, afterRight.x, clamp),
        y.map(beforeLeft.y, beforeRight.y, afterLeft.y, afterRight.y, clamp),
        z.map(beforeLeft.z, beforeRight.z, afterLeft.z, afterRight.z, clamp)
    )

fun<N:Number> Vector4<N, *>.map(
                beforeLeft: Vector4<N, *>,
                beforeRight: Vector4<N, *>,
                afterLeft: Vector4<N, *>,
                afterRight: Vector4<N, *>,
                clamp: Boolean = false) =
    create(x.map(beforeLeft.x, beforeRight.x, afterLeft.x, afterRight.x, clamp),
        y.map(beforeLeft.y, beforeRight.y, afterLeft.y, afterRight.y, clamp),
        z.map(beforeLeft.z, beforeRight.z, afterLeft.z, afterRight.z, clamp),
        w.map(beforeLeft.w, beforeRight.w, afterLeft.w, afterRight.w, clamp)
    )
